<?php
$test_n = 5000;

$a = array();
$b = array();
$begin = microtime(true);
//随机生成序列
for($i=0;$i < $test_n;$i++)
{
	$a[] = rand(0,$test_n*2);
	$b[] = rand(0,$test_n*2);
}
$end = microtime(true);
$aa = $a;
$bb = $b;
//统计运行时间
echo "build array cost ".($end-$begin)."n";
//test函数 用于多种算法测试
function test($name,$aa,$bb,$fun=null)
{
	$begin = microtime(true);
	if(!empty($fun)){
		$fun($aa);
		$fun($bb);
	}
	$c=$name($aa,$bb);
	$d=$name($bb,$aa);
	$end = microtime(true);
	print_r(count($c)." ");
	print_r(count($d)." ");
	echo "$name cost ".($end-$begin)."n";
}
//array_diff
test("array_diff",$a,$b);

?>

